package gui.visu.listeners;

import java.awt.event.MouseWheelEvent;
import java.awt.event.MouseWheelListener;

import controls.DataControl;
import data.Constants;


/**
 * @author Charles Perin
 * 29 mars 2011
 * LIMSI - INRIA Rennes
 * charles.perin@free.fr
 *
 */
public class ListenerZoomMouseWheel implements MouseWheelListener{

	private DataControl dataControl;
	
	public ListenerZoomMouseWheel(DataControl dataControl){
		setDataControl(dataControl);
	}
	
	
	@Override
	public void mouseWheelMoved(MouseWheelEvent e) {
		int notches = e.getWheelRotation();
		if (notches < 0) {
			//zoom in
			dataControl.getDisplayDataList().zoom(dataControl.getZoomStepWheel(), Constants.ZOOM_IN);
			dataControl.updateVisuPane();
		} else {
			//zoom out
			dataControl.getDisplayDataList().zoom(dataControl.getZoomStepWheel(), Constants.ZOOM_OUT);
			dataControl.updateVisuPane();
		}
	}


	public DataControl getDataControl() {
		return dataControl;
	}


	public void setDataControl(DataControl dataControl) {
		this.dataControl = dataControl;
	}


}
